<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
<title>KindEditor 4.x Documentation</title>
    
    <link rel="stylesheet" href="_static/classy.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '4.x',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="KindEditor 4.x documentation" href="index.html" />
    <link rel="next" title="Range API" href="range.html" />
    <link rel="prev" title="选择器(Selector) API" href="selector.html" /> 
  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="range.html" title="Range API"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="selector.html" title="选择器(Selector) API"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">KindEditor 4.x documentation</a> &raquo;</li> 
      </ul>
    </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="node-api">
<h1><a class="toc-backref" href="#id1">Node API</a><a class="headerlink" href="#node-api" title="Permalink to this headline">¶</a></h1>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#node-api" id="id1">Node API</a><ul>
<li><a class="reference internal" href="#k-expr-root" id="id2">K(expr , root)</a></li>
<li><a class="reference internal" href="#length" id="id3">length</a></li>
<li><a class="reference internal" href="#doc" id="id4">doc</a></li>
<li><a class="reference internal" href="#name" id="id5">name</a></li>
<li><a class="reference internal" href="#type" id="id6">type</a></li>
<li><a class="reference internal" href="#bind-type-fn" id="id7">bind(type , fn)</a></li>
<li><a class="reference internal" href="#unbind-type-fn" id="id8">unbind([type , fn])</a></li>
<li><a class="reference internal" href="#fire-type" id="id9">fire(type)</a></li>
<li><a class="reference internal" href="#hasattr-key" id="id10">hasAttr(key)</a></li>
<li><a class="reference internal" href="#attr" id="id11">attr()</a></li>
<li><a class="reference internal" href="#attr-key" id="id12">attr(key)</a></li>
<li><a class="reference internal" href="#attr-key-val" id="id13">attr(key, val)</a></li>
<li><a class="reference internal" href="#attr-obj" id="id14">attr(obj)</a></li>
<li><a class="reference internal" href="#removeattr-key" id="id15">removeAttr(key)</a></li>
<li><a class="reference internal" href="#get-i" id="id16">get([i])</a></li>
<li><a class="reference internal" href="#eq-i" id="id17">eq(i)</a></li>
<li><a class="reference internal" href="#hasclass-cls" id="id18">hasClass(cls)</a></li>
<li><a class="reference internal" href="#addclass-cls" id="id19">addClass(cls)</a></li>
<li><a class="reference internal" href="#removeclass-cls" id="id20">removeClass(cls)</a></li>
<li><a class="reference internal" href="#html" id="id21">html()</a></li>
<li><a class="reference internal" href="#html-val" id="id22">html(val)</a></li>
<li><a class="reference internal" href="#hasval" id="id23">hasVal()</a></li>
<li><a class="reference internal" href="#val" id="id24">val()</a></li>
<li><a class="reference internal" href="#val-val" id="id25">val(val)</a></li>
<li><a class="reference internal" href="#css" id="id26">css()</a></li>
<li><a class="reference internal" href="#css-key" id="id27">css(key)</a></li>
<li><a class="reference internal" href="#css-key-val" id="id28">css(key, val)</a></li>
<li><a class="reference internal" href="#css-obj" id="id29">css(obj)</a></li>
<li><a class="reference internal" href="#width" id="id30">width()</a></li>
<li><a class="reference internal" href="#width-val" id="id31">width(val)</a></li>
<li><a class="reference internal" href="#height" id="id32">height()</a></li>
<li><a class="reference internal" href="#height-val" id="id33">height(val)</a></li>
<li><a class="reference internal" href="#opacity-val" id="id34">opacity(val)</a></li>
<li><a class="reference internal" href="#data-key" id="id35">data(key)</a></li>
<li><a class="reference internal" href="#data-key-val" id="id36">data(key, val)</a></li>
<li><a class="reference internal" href="#pos" id="id37">pos()</a></li>
<li><a class="reference internal" href="#clone-bool" id="id38">clone(bool)</a></li>
<li><a class="reference internal" href="#append-expr" id="id39">append(expr)</a></li>
<li><a class="reference internal" href="#before-expr" id="id40">before(expr)</a></li>
<li><a class="reference internal" href="#after-expr" id="id41">after(expr)</a></li>
<li><a class="reference internal" href="#replacewith-expr" id="id42">replaceWith(expr)</a></li>
<li><a class="reference internal" href="#remove-keepchilds" id="id43">remove([keepChilds])</a></li>
<li><a class="reference internal" href="#show-val" id="id44">show([val])</a></li>
<li><a class="reference internal" href="#hide" id="id45">hide()</a></li>
<li><a class="reference internal" href="#outer" id="id46">outer()</a></li>
<li><a class="reference internal" href="#issingle" id="id47">isSingle()</a></li>
<li><a class="reference internal" href="#isinline" id="id48">isInline()</a></li>
<li><a class="reference internal" href="#isblock" id="id49">isBlock()</a></li>
<li><a class="reference internal" href="#contains-othernode" id="id50">contains(otherNode)</a></li>
<li><a class="reference internal" href="#parent" id="id51">parent()</a></li>
<li><a class="reference internal" href="#children" id="id52">children()</a></li>
<li><a class="reference internal" href="#first" id="id53">first()</a></li>
<li><a class="reference internal" href="#last" id="id54">last()</a></li>
<li><a class="reference internal" href="#index" id="id55">index()</a></li>
<li><a class="reference internal" href="#prev" id="id56">prev()</a></li>
<li><a class="reference internal" href="#next" id="id57">next()</a></li>
<li><a class="reference internal" href="#scan-fn-order" id="id58">scan(fn [, order])</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="k-expr-root">
<span id="k"></span><span id="index-0"></span><h2><a class="toc-backref" href="#id2">K(expr , root)</a><a class="headerlink" href="#k-expr-root" title="Permalink to this headline">¶</a></h2>
<p>创建或选取KNode对象，KNode是原生node的封装，KNode对象拥有以下属性和方法。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string|node expr: DOM元素、选择器表达式、HTML代码</li>
<li>element root: DOM根元素，在root范围内选择DOM元素</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">node</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;&lt;div&gt;abc&lt;/div&gt;&#39;</span><span class="p">);</span>
<span class="nx">node</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">);</span>
<span class="nx">node</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">));</span>
<span class="nx">firstNode</span> <span class="o">=</span> <span class="nx">node</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
</pre></div>
</div>
</div>
<div class="section" id="length">
<span id="knode-length"></span><span id="index-1"></span><h2><a class="toc-backref" href="#id3">length</a><a class="headerlink" href="#length" title="Permalink to this headline">¶</a></h2>
<p>node数量</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">length</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">length</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="doc">
<span id="knode-doc"></span><span id="index-2"></span><h2><a class="toc-backref" href="#id4">doc</a><a class="headerlink" href="#doc" title="Permalink to this headline">¶</a></h2>
<p>第一个node的document对象。</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">doc</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">doc</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="name">
<span id="knode-name"></span><span id="index-3"></span><h2><a class="toc-backref" href="#id5">name</a><a class="headerlink" href="#name" title="Permalink to this headline">¶</a></h2>
<p>第一个node的nodeName。</p>
</div>
<div class="section" id="type">
<span id="knode-type"></span><span id="index-4"></span><h2><a class="toc-backref" href="#id6">type</a><a class="headerlink" href="#type" title="Permalink to this headline">¶</a></h2>
<p>第一个node的nodeType。1: Element, 3: textNode</p>
</div>
<div class="section" id="bind-type-fn">
<span id="knode-bind"></span><span id="index-5"></span><h2><a class="toc-backref" href="#id7">bind(type , fn)</a><a class="headerlink" href="#bind-type-fn" title="Permalink to this headline">¶</a></h2>
<p>将指定函数绑定到所有KNode的指定事件上。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string type: 事件类型</li>
<li>function fn: 回调函数</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="nx">alert</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">+</span> <span class="s1">&#39;: clicked&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="nx">alert</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">+</span> <span class="s1">&#39;: clicked&#39;</span><span class="p">);</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
<div class="section" id="unbind-type-fn">
<span id="knode-unbind"></span><span id="index-6"></span><h2><a class="toc-backref" href="#id8">unbind([type , fn])</a><a class="headerlink" href="#unbind-type-fn" title="Permalink to this headline">¶</a></h2>
<p>移除已绑定的事件函数。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string type: 事件类型</li>
<li>function fn: 回调函数</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">unbind</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="nx">functionName</span><span class="p">);</span> <span class="c1">//移除指定的事件函数</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">unbind</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">);</span> <span class="c1">//移除所有click事件函数</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">unbind</span><span class="p">();</span> <span class="c1">//移除所有事件函数</span>
</pre></div>
</div>
</div>
<div class="section" id="fire-type">
<span id="knode-fire"></span><span id="index-7"></span><h2><a class="toc-backref" href="#id9">fire(type)</a><a class="headerlink" href="#fire-type" title="Permalink to this headline">¶</a></h2>
<p>执行绑定在第一个node上的事件函数。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string type: 事件类型</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">fire</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="hasattr-key">
<span id="knode-hasattr"></span><span id="index-8"></span><h2><a class="toc-backref" href="#id10">hasAttr(key)</a><a class="headerlink" href="#hasattr-key" title="Permalink to this headline">¶</a></h2>
<p>判断第一个node是否拥有指定属性。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: 属性名</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: boolean</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">bool</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">hasAttr</span><span class="p">(</span><span class="s1">&#39;border&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="attr">
<span id="knode-attr"></span><span id="index-9"></span><h2><a class="toc-backref" href="#id11">attr()</a><a class="headerlink" href="#attr" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的所有属性.</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: object</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">attrList</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">();</span> <span class="c1">//return key-value data</span>
</pre></div>
</div>
</div>
<div class="section" id="attr-key">
<h2><a class="toc-backref" href="#id12">attr(key)</a><a class="headerlink" href="#attr-key" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的指定属性.</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: 属性名</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: string</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">border</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;border&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="attr-key-val">
<h2><a class="toc-backref" href="#id13">attr(key, val)</a><a class="headerlink" href="#attr-key-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的属性。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: 属性名</li>
<li>string val: 属性值</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id img&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;border&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="attr-obj">
<h2><a class="toc-backref" href="#id14">attr(obj)</a><a class="headerlink" href="#attr-obj" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的多个属性。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>object obj: key-value数组</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id img&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">({</span>
        <span class="s1">&#39;width&#39;</span> <span class="o">:</span> <span class="s1">&#39;100px&#39;</span><span class="p">,</span>
        <span class="s1">&#39;border&#39;</span> <span class="o">:</span> <span class="mi">1</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
<div class="section" id="removeattr-key">
<span id="knode-removeattr"></span><span id="index-10"></span><h2><a class="toc-backref" href="#id15">removeAttr(key)</a><a class="headerlink" href="#removeattr-key" title="Permalink to this headline">¶</a></h2>
<p>移除所有node的指定属性.</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: 属性名</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id img&#39;</span><span class="p">).</span><span class="nx">removeAttr</span><span class="p">(</span><span class="s1">&#39;border&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="get-i">
<span id="knode-get"></span><span id="index-11"></span><h2><a class="toc-backref" href="#id16">get([i])</a><a class="headerlink" href="#get-i" title="Permalink to this headline">¶</a></h2>
<p>取得原生node，当KNode的length为0时，返回null.</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>int i: offset，默认值为0</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: node</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">div1</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">get</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="nx">div2</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">get</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="eq-i">
<span id="knode-eq"></span><span id="index-12"></span><h2><a class="toc-backref" href="#id17">eq(i)</a><a class="headerlink" href="#eq-i" title="Permalink to this headline">¶</a></h2>
<p>将KNode对象转换成length为1的KNode对象。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>int i: The index of the element in the KNode object.</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">).</span><span class="nx">eq</span><span class="p">(</span><span class="mi">2</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;blue&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="hasclass-cls">
<span id="knode-hasclass"></span><span id="index-13"></span><h2><a class="toc-backref" href="#id18">hasClass(cls)</a><a class="headerlink" href="#hasclass-cls" title="Permalink to this headline">¶</a></h2>
<p>判断第一个node是否拥有指定class。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string cls: className</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: boolean</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">bool</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">hasClass</span><span class="p">(</span><span class="s1">&#39;class-name&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="addclass-cls">
<span id="knode-addclass"></span><span id="index-14"></span><h2><a class="toc-backref" href="#id19">addClass(cls)</a><a class="headerlink" href="#addclass-cls" title="Permalink to this headline">¶</a></h2>
<p>将指定className添加到所有node。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string cls: className</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;class-name&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="removeclass-cls">
<span id="knode-removeclass"></span><span id="index-15"></span><h2><a class="toc-backref" href="#id20">removeClass(cls)</a><a class="headerlink" href="#removeclass-cls" title="Permalink to this headline">¶</a></h2>
<p>移除所有node上的指定className。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string cls: className</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;class-name&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="html">
<span id="knode-html"></span><span id="index-16"></span><h2><a class="toc-backref" href="#id21">html()</a><a class="headerlink" href="#html" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的innerHTML。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: string</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">html</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">html</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="html-val">
<h2><a class="toc-backref" href="#id22">html(val)</a><a class="headerlink" href="#html-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的innerHTML。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string val: HTML字符串</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="s1">&#39;&lt;strong&gt;abc&lt;/strong&gt;&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="hasval">
<span id="knode-hasval"></span><span id="index-17"></span><h2><a class="toc-backref" href="#id23">hasVal()</a><a class="headerlink" href="#hasval" title="Permalink to this headline">¶</a></h2>
<p>判断第一个node是否拥有value属性。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: boolean</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">bool</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#textarea&#39;</span><span class="p">).</span><span class="nx">hasVal</span><span class="p">();</span> <span class="c1">//return true</span>
<span class="nx">bool</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#div&#39;</span><span class="p">).</span><span class="nx">hasVal</span><span class="p">();</span> <span class="c1">//return false</span>
</pre></div>
</div>
</div>
<div class="section" id="val">
<span id="knode-val"></span><span id="index-18"></span><h2><a class="toc-backref" href="#id24">val()</a><a class="headerlink" href="#val" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的value。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: string</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#textarea&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="val-val">
<h2><a class="toc-backref" href="#id25">val(val)</a><a class="headerlink" href="#val-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的value。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#textarea&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;abc&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="css">
<span id="knode-css"></span><span id="index-19"></span><h2><a class="toc-backref" href="#id26">css()</a><a class="headerlink" href="#css" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的所有CSS.</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: object</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">cssList</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">();</span> <span class="c1">//return key-value data</span>
</pre></div>
</div>
</div>
<div class="section" id="css-key">
<h2><a class="toc-backref" href="#id27">css(key)</a><a class="headerlink" href="#css-key" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的指定CSS.</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: CSS key</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: string</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">padding</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s1">&#39;padding&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="css-key-val">
<h2><a class="toc-backref" href="#id28">css(key, val)</a><a class="headerlink" href="#css-key-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的CSS。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: CSS key</li>
<li>string val: CSS value</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s1">&#39;border&#39;</span><span class="p">,</span> <span class="s1">&#39;1px solid #000&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="css-obj">
<h2><a class="toc-backref" href="#id29">css(obj)</a><a class="headerlink" href="#css-obj" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的多个CSS。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>object obj: key-value数组</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">({</span>
        <span class="s1">&#39;width&#39;</span> <span class="o">:</span> <span class="s1">&#39;100px&#39;</span><span class="p">,</span>
        <span class="s1">&#39;height&#39;</span> <span class="o">:</span> <span class="s1">&#39;50px&#39;</span><span class="p">,</span>
        <span class="s1">&#39;padding&#39;</span> <span class="o">:</span> <span class="s1">&#39;10px&#39;</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
<div class="section" id="width">
<span id="knode-width"></span><span id="index-20"></span><h2><a class="toc-backref" href="#id30">width()</a><a class="headerlink" href="#width" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的宽度(px).</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: int</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">width</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">width</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="width-val">
<h2><a class="toc-backref" href="#id31">width(val)</a><a class="headerlink" href="#width-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的宽度。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string val: 宽度</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">width</span><span class="p">(</span><span class="mi">200</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">width</span><span class="p">(</span><span class="s1">&#39;200px&#39;</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">width</span><span class="p">(</span><span class="s1">&#39;100%&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="height">
<span id="knode-height"></span><span id="index-21"></span><h2><a class="toc-backref" href="#id32">height()</a><a class="headerlink" href="#height" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的高度(px).</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: int</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">height</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">height</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="height-val">
<h2><a class="toc-backref" href="#id33">height(val)</a><a class="headerlink" href="#height-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的高度。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string val: 高度</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">height</span><span class="p">(</span><span class="mi">200</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">height</span><span class="p">(</span><span class="s1">&#39;200px&#39;</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id div&#39;</span><span class="p">).</span><span class="nx">height</span><span class="p">(</span><span class="s1">&#39;100%&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="opacity-val">
<span id="knode-opacity"></span><span id="index-22"></span><h2><a class="toc-backref" href="#id34">opacity(val)</a><a class="headerlink" href="#opacity-val" title="Permalink to this headline">¶</a></h2>
<p>设置所有node的透明度.</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>float val: 透明度，0~1</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">opacity</span><span class="p">(</span><span class="mf">0.5</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="data-key">
<span id="knode-data"></span><span id="index-23"></span><h2><a class="toc-backref" href="#id35">data(key)</a><a class="headerlink" href="#data-key" title="Permalink to this headline">¶</a></h2>
<p>取得已绑定的自定义数据。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: data key</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: string</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;data_id&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="data-key-val">
<h2><a class="toc-backref" href="#id36">data(key, val)</a><a class="headerlink" href="#data-key-val" title="Permalink to this headline">¶</a></h2>
<p>绑定自定义数据。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string key: data key</li>
<li>string val: data value</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: string</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;abc&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="pos">
<span id="knode-pos"></span><span id="index-24"></span><h2><a class="toc-backref" href="#id37">pos()</a><a class="headerlink" href="#pos" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node在整个document上的x坐标和y坐标。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: string</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">pos</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">pos</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">pos</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="nx">pos</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="clone-bool">
<span id="knode-clone"></span><span id="index-25"></span><h2><a class="toc-backref" href="#id38">clone(bool)</a><a class="headerlink" href="#clone-bool" title="Permalink to this headline">¶</a></h2>
<p>复制第一个node，并返回第一个node的KNode。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>boolean bool: true时复制所有子节点，false时只复制父节点</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: 新的KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">newKNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">clone</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="append-expr">
<span id="knode-append"></span><span id="index-26"></span><h2><a class="toc-backref" href="#id39">append(expr)</a><a class="headerlink" href="#append-expr" title="Permalink to this headline">¶</a></h2>
<p>element添加一个子节点。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string|node expr: DOM元素、选择器表达式、HTML代码</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">divNode</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;div class=&quot;abc&quot;&gt;def&lt;/div&gt;&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="before-expr">
<span id="knode-before"></span><span id="index-27"></span><h2><a class="toc-backref" href="#id40">before(expr)</a><a class="headerlink" href="#before-expr" title="Permalink to this headline">¶</a></h2>
<p>node的前面添加一个节点。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string|node expr: DOM元素、选择器表达式、HTML代码</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">before</span><span class="p">(</span><span class="nx">divNode</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">before</span><span class="p">(</span><span class="s1">&#39;&lt;div class=&quot;abc&quot;&gt;def&lt;/div&gt;&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="after-expr">
<span id="knode-after"></span><span id="index-28"></span><h2><a class="toc-backref" href="#id41">after(expr)</a><a class="headerlink" href="#after-expr" title="Permalink to this headline">¶</a></h2>
<p>node的后面添加一个节点。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string|node expr: DOM元素、选择器表达式、HTML代码</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">after</span><span class="p">(</span><span class="nx">divNode</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">after</span><span class="p">(</span><span class="s1">&#39;&lt;div class=&quot;abc&quot;&gt;def&lt;/div&gt;&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="replacewith-expr">
<span id="knode-replacewith"></span><span id="index-29"></span><h2><a class="toc-backref" href="#id42">replaceWith(expr)</a><a class="headerlink" href="#replacewith-expr" title="Permalink to this headline">¶</a></h2>
<p>替换node。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string|node expr: DOM元素、选择器表达式、HTML代码</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">replaceWith</span><span class="p">(</span><span class="nx">divNode</span><span class="p">);</span>
<span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">replaceWith</span><span class="p">(</span><span class="s1">&#39;&lt;div class=&quot;abc&quot;&gt;def&lt;/div&gt;&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="remove-keepchilds">
<span id="knode-remove"></span><span id="index-30"></span><h2><a class="toc-backref" href="#id43">remove([keepChilds])</a><a class="headerlink" href="#remove-keepchilds" title="Permalink to this headline">¶</a></h2>
<p>删除node。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>boolean keepChilds: 是否保留子节点，true或false，默认值为false</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">remove</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="show-val">
<span id="knode-show"></span><span id="index-31"></span><h2><a class="toc-backref" href="#id44">show([val])</a><a class="headerlink" href="#show-val" title="Permalink to this headline">¶</a></h2>
<p>显示element。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>string val: display的值，默认值为block</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">show</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="hide">
<span id="knode-hide"></span><span id="index-32"></span><h2><a class="toc-backref" href="#id45">hide()</a><a class="headerlink" href="#hide" title="Permalink to this headline">¶</a></h2>
<p>隐藏element。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">hide</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="outer">
<span id="knode-outer"></span><span id="index-33"></span><h2><a class="toc-backref" href="#id46">outer()</a><a class="headerlink" href="#outer" title="Permalink to this headline">¶</a></h2>
<p>取得第一个element的outerHTML。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: string</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">html</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">outer</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="issingle">
<span id="knode-issingle"></span><span id="index-34"></span><h2><a class="toc-backref" href="#id47">isSingle()</a><a class="headerlink" href="#issingle" title="Permalink to this headline">¶</a></h2>
<p>判断第一个element是否有闭合标签。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: boolean</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">).</span><span class="nx">isSingle</span><span class="p">())</span> <span class="p">{</span>
        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;false&#39;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="isinline">
<span id="knode-isinline"></span><span id="index-35"></span><h2><a class="toc-backref" href="#id48">isInline()</a><a class="headerlink" href="#isinline" title="Permalink to this headline">¶</a></h2>
<p>判断第一个element是不是inline element。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: boolean</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">).</span><span class="nx">isInline</span><span class="p">())</span> <span class="p">{</span>
        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;false&#39;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="isblock">
<span id="knode-isblock"></span><span id="index-36"></span><h2><a class="toc-backref" href="#id49">isBlock()</a><a class="headerlink" href="#isblock" title="Permalink to this headline">¶</a></h2>
<p>判断第一个element是不是block element。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: boolean</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">).</span><span class="nx">isBlock</span><span class="p">())</span> <span class="p">{</span>
        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;true&#39;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="contains-othernode">
<span id="knode-contains"></span><span id="index-37"></span><h2><a class="toc-backref" href="#id50">contains(otherNode)</a><a class="headerlink" href="#contains-othernode" title="Permalink to this headline">¶</a></h2>
<p>判断第一个element是否包含指定node。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>node otherNode: 任意节点</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: boolean</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div#id&#39;</span><span class="p">).</span><span class="nx">contains</span><span class="p">(</span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div#id p&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]))</span> <span class="p">{</span>
        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;true&#39;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="parent">
<span id="knode-parent"></span><span id="index-38"></span><h2><a class="toc-backref" href="#id51">parent()</a><a class="headerlink" href="#parent" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的父节点。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">parentNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">parent</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="children">
<span id="knode-children"></span><span id="index-39"></span><h2><a class="toc-backref" href="#id52">children()</a><a class="headerlink" href="#children" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的子节点列表。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">children</span><span class="p">().</span><span class="nx">css</span><span class="p">(</span><span class="s1">&#39;color&#39;</span><span class="p">,</span> <span class="s1">&#39;red&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="first">
<span id="knode-first"></span><span id="index-40"></span><h2><a class="toc-backref" href="#id53">first()</a><a class="headerlink" href="#first" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的第一个子节点。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">firstNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">first</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="last">
<span id="knode-last"></span><span id="index-41"></span><h2><a class="toc-backref" href="#id54">last()</a><a class="headerlink" href="#last" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的最后一个子节点。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">lastNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">last</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="index">
<span id="knode-index"></span><span id="index-42"></span><h2><a class="toc-backref" href="#id55">index()</a><a class="headerlink" href="#index" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node在父节点中的偏移位置。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: int</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div#id p&#39;</span><span class="p">).</span><span class="nx">index</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="prev">
<span id="knode-prev"></span><span id="index-43"></span><h2><a class="toc-backref" href="#id56">prev()</a><a class="headerlink" href="#prev" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的上一个节点。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">prevNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">prev</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="next">
<span id="knode-next"></span><span id="index-44"></span><h2><a class="toc-backref" href="#id57">next()</a><a class="headerlink" href="#next" title="Permalink to this headline">¶</a></h2>
<p>取得第一个node的下一个节点。</p>
<ul class="simple">
<li>参数: 无</li>
<li>返回: KNode</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">nextNode</span> <span class="o">=</span> <span class="nx">K</span><span class="p">(</span><span class="s1">&#39;#id&#39;</span><span class="p">).</span><span class="nx">next</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="scan-fn-order">
<span id="knode-scan"></span><span id="index-45"></span><h2><a class="toc-backref" href="#id58">scan(fn [, order])</a><a class="headerlink" href="#scan-fn-order" title="Permalink to this headline">¶</a></h2>
<p>遍历第一个node的所有子节点。</p>
<ul>
<li><dl class="first docutils">
<dt>参数:</dt>
<dd><ul class="first last simple">
<li>function fn: 回调函数</li>
<li>boolean order: 遍历方向，true为顺序，false为逆序，默认值为true</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">返回: KNode</p>
</li>
</ul>
<p>示例:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">K</span><span class="p">(</span><span class="s1">&#39;div#id&#39;</span><span class="p">).</span><span class="nx">scan</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span> <span class="p">(</span>
        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
<span class="p">));</span>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="range.html" title="Range API"
             >next</a> |</li>
        <li class="right" >
          <a href="selector.html" title="选择器(Selector) API"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">KindEditor 4.x documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &copy; Copyright kindsoft.net.
    </div>
  </body>
</html>